package com.leyou.item.mapper;

import com.leyou.item.pojo.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @Author: wht
 * @Date: 2018-12-17 11:02
 */
public interface CategoryMapper extends Mapper<Category>, SelectByIdListMapper<Category, Long> {
    @Select("SELECT * FROM tb_category WHERE id IN (SELECT category_id FROM tb_category_brand WHERE brand_id = #{bid});")
    List<Category> queryByBrandId(@Param("bid") Long bid);

    @Delete("DELETE FROM tb_brand WHERE id = #{did};")
    void deleteById(@Param("did") Long did);

    @Delete("DELETE FROM tb_category_brand WHERE brand_id = #{did};")
    void deleteByBrandId(@Param("did") Long did);
}
